package com.example.springalibabacloudclient.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.springalibabacloudclient.utils.Results;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Classname ClientController
 * @Description TODO
 * @Date 2022/5/14 11:12
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@RestController
@RefreshScope
@Slf4j
@RequestMapping("/config")
public class ConfigController {

    @Value("${test.value}")
    public String testValue;

    @GetMapping
    public JSONObject valueController(){
        return Results.success("从配置中心动态获取值: "+testValue);
    }

    @GetMapping("v1")
    public JSONObject v1Controller(){
        log.info("访问配置中心了===>");
        return Results.success("访问成功");
    }
}
